package com.zelin.advice;


import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;

import org.springframework.stereotype.Component;

@Aspect
@Component
public class MyAdvice2 {
   @Pointcut("execution(* com.zelin.dao.impl.*DaoImpl.*(..))")
   public  void pc(){}
   @Before("MyAdvice2.pc()")
   public void before(){
      System.out.println("myadvice2--->前置通知");
   }
   @AfterReturning("MyAdvice2.pc()")
   public void afterReturning(){
      System.out.println("MyAdvice2-->后置通知，出现异常不调用.");
   }
   @Around("MyAdvice2.pc()")
   public Object around(ProceedingJoinPoint pjp) throws Throwable{
      System.out.println("MyAdvice2-->环绕通知-前面代码");
      Object proceed = pjp.proceed();
      System.out.println("MyAdvice2-->环绕通知-后面代码");
      return proceed;
   }
   @AfterThrowing("MyAdvice2.pc()")
   public void afterThrowing(){
      System.out.println("myadvice-->出现异常【后置通知】");
      }
      @After("MyAdvice2.pc()")
   public  void after(){
         System.out.println("MyAdvice2-->无论是否出现异常，都会调用！【后置通知】");
      }
   }

